from typing import *
from leetcode.editor.common.node import *


# leetcode submit region begin(Prohibit modification and deletion)
class Solution(object):
    def simplifyPath(self, path):
        paths = path.split('/')
        print(paths)
        stack = []
        for p in paths:
            if p == '' or p == '.':
                continue
            elif p == '..':
                if len(stack) >0:
                    stack.pop(-1)
            else:
                stack.append(p)
        return '/' + '/'.join(stack)
        
# leetcode submit region end(Prohibit modification and deletion)


if __name__ == '__main__':
    solution = Solution()
    print(solution.simplifyPath('/.../a/../b/c/../d/./'))
    # your test code here